class Company < ActiveRecord::Base
  has_many :people
  belongs_to :address, :dependent => true
  
  validates_presence_of :name, :message => "Please enter a company name"
  
  def validate
    begin
      Address.find address_id
    rescue ActiveRecord::RecordNotFound
      errors.add(:address_id, 'Address with that ID does not exist')
    end
  end
end
